package com.oauth2_security.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import com.oauth2_security.dao.UserDao;
import com.oauth2_security.entity.UserInfo;
import com.oauth2_security.service.UserService;

@Service
public class UserServiceImpl implements UserService{

	@Autowired
	private UserDao userDao;
	
	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		UserInfo user = null;
		try {
			user = userDao.findByUsername(username);
		}catch (Exception e) {
			user = userDao.findByUserNickname(username);
		}
		
		return user;
	}

	
}
